module TestHelper(assertException, (@!)) where

import Test.HUnit
import Control.OldException

-- How do I get this to work with Control.Exception?
shouldBeException :: (IO (Either a b)) -> Assertion
shouldBeException x = do
  val <- x
  checkForException val where
      checkForException (Left _) = return ()
      checkForException (Right _) = assertFailure "Didn't get exception"

assertException :: String -> a -> Assertion
assertException msg val = do
  shouldBeException (try (evaluate val))

infix 1 @!

(@!) msg val = TestCase (assertException msg val)
